package com.ipfsemc.ipfsemc.wx.menu;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.weixin4j.model.message.Articles;
import org.weixin4j.model.message.OutputMessage;
import org.weixin4j.model.message.normal.*;
import org.weixin4j.model.message.output.NewsOutputMessage;
import org.weixin4j.model.message.output.TextOutputMessage;
import org.weixin4j.spi.INormalMessageHandler;

import java.util.ArrayList;
import java.util.List;

/**
 * 自定义普通消息处理器
 *
 * @author yangqisheng
 */
@Component
public class MyAtsNormalMessageHandler implements INormalMessageHandler {

    protected final Logger LOG = LoggerFactory.getLogger(MyAtsNormalMessageHandler.class);

    @Override
    public OutputMessage textTypeMsg(TextInputMessage msg) {
        LOG.debug("文本消息：" + msg.getContent());
        NewsOutputMessage outputMessage=new NewsOutputMessage();
        List<Articles> list=new ArrayList<>();

        Articles articles=new Articles();
        articles.setTitle("IPFS超级存储革命-Filecoin科普访谈");
        articles.setPicUrl("https://mmbiz.qpic.cn/mmbiz_jpg/9sQH25udFRYqtojGjFiaIU74d8Q6LrwFv7iboiasXJ39vSB69GAvsLBn0BNHOI7ufKVh8rebmw5grCibpbNpXpFjjA/0?wx_fmt=jpeg");
        articles.setUrl("https://mp.weixin.qq.com/s/MH6LEYHyTZMHBExbjmnClA");
        articles.setDescription("科普IPFS&FIL的工作原理、投资价值、参与方式、投资收益、投资风险以及IPFS易迈云相关。");

        Articles a2=new Articles();
        a2.setDescription("描述");
        a2.setTitle("标题");
        a2.setPicUrl("https://mmbiz.qpic.cn/mmbiz_png/9sQH25udFRbVKVTqkLttEHfAznbWcVNrrCyib9mxL0ojpPpyj6y4zsNl2dibkgDdIzeyGIodkt6MsmMg5ge2Kp5Q/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1");
        a2.setUrl("https://mp.weixin.qq.com/s/yMKtwEmpZ3ZRcv95yn67fA");

        list.add(articles);
        list.add(a2);

        outputMessage.setArticles(list);

//        TextOutputMessage out = new TextOutputMessage();
//        out.setContent("https://mp.weixin.qq.com/s/MH6LEYHyTZMHBExbjmnClA");
//        out.setContent("您发的消息是：" + msg.getContent());

        //if
        return outputMessage;
    }

    @Override
    public OutputMessage imageTypeMsg(ImageInputMessage msg) {
        TextOutputMessage out = new TextOutputMessage();
        out.setContent("你的消息已经收到！11");
        return out;
    }

    @Override
    public OutputMessage voiceTypeMsg(VoiceInputMessage msg) {
        TextOutputMessage out = new TextOutputMessage();
        out.setContent("你的消息已经收到！22");
        return out;
    }

    @Override
    public OutputMessage videoTypeMsg(VideoInputMessage msg) {
        TextOutputMessage out = new TextOutputMessage();
        out.setContent("你的消息已经收到！33");
        return out;
    }

    @Override
    public OutputMessage shortvideoTypeMsg(ShortVideoInputMessage msg) {
        TextOutputMessage out = new TextOutputMessage();
        out.setContent("你的消息已经收到！44");
        return out;
    }

    @Override
    public OutputMessage locationTypeMsg(LocationInputMessage msg) {
        TextOutputMessage out = new TextOutputMessage();
        out.setContent("你的消息已经收到！55");
        return out;
    }

    @Override
    public OutputMessage linkTypeMsg(LinkInputMessage msg) {
        TextOutputMessage out = new TextOutputMessage();
        out.setContent("你的消息已经收到！66");
        return out;
    }

}
